home *** CD-ROM | disk | FTP | other *** search
- Path: news.deltanet.com!usenet
- From: Robert Taylor <btaylor@deltanet.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a standard for * and & placement style?
- Date: Wed, 21 Feb 1996 21:26:14 -0800
- Organization: Delta Internet Services, Anaheim, CA
- Message-ID: <312BFE76.A9@deltanet.com>
- References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com>
- <4gckd5$bc7@clarknet.clark.net> <egpwb896e6.fsf@vipe.ii.uib.no> <312B5F0F.CFE@trpo4.tr.unisys.com>
- NNTP-Posting-Host: ana0023.deltanet.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Benjamin Romer wrote:
- >
- > Ketil Z Malde wrote:
- > >
- > > Discussing
- > >
- > > int *ip;
- > > vs. int* ip;
- > >
- > > one might also observe that "*ip" is, in fact, an int, just as much as
- > > "ip" is an int*. Just my two *.
- > >
- > > -kzm
- > >
- >
- > Actually there has been a great deal of argument about which is considered
- > "correct", even though both work.
- >
- > IMHO, the first method (int *ip) is safer for beginners, who might expect
- >
- > int* a, b, c;
- >
- > To define three pointers, while it in fact only defines one. This belief is
- > further reinforced in a beginner's view by the use of * in typecasting,
- > e.g. you must write (int*)ptrToAChar to get a pointer; if you write
- > (int)*ptrToAChar you actually get an int. (I know you don't have to typecast
- > char to int, it's only an example.) If you only define one variable per
- > statement, though, it looks and works just fine; personally, I'd write
- >
- > int *a, *b, *c;
- >
- > But that may just be stubbornness (and the fact that I've been using
- > that format since college). Some would even go so far as to insist on
- > using a typedef for pointers:
- >
- > typedef int * ptrInt;
- >
- > ptrInt ip, a, b, c;
- >
- > This may be the safest way to do it but personally I think its a waste
- > of typing.
- >
- > This is all merely opinion, though, and it really doesn't matter what you
- > use as long as it compiles and your meaning is clear.
- >
- > $0.02
- >
- > Freely yours,
- >
- > Ben Romer
- > Software Engineer
- > Unisys Corporation
- >
- > #include <stddisclaim.h>
-
- I am one who would insist on a typedef...
- typedef int FAR * LPINT;
-
- LPINT lpInteger;
-
- I would also insist on Hungarian notation ;)
-
- $0.0025
-
- -- Bob T.
-